package com.amado.course15Constructor;

/**
 * 以前的用法
 * new String[]{"张三","1","18252131231"}
 * setName("张三");
 * setAge(1);
 * 
 * 现在使用
 * 构造方法，
 * 所有的类默认都有一个空的构造方法,如果添加了自定义的构造方法，默认的方法就会被覆盖（不能调用）
 * 构建方法可以通过访问修饰符修饰
 * 方法名必须跟类名一样，并且没有返回值和void
 */
public class StudentConstructor {
	private String name;
	private String age;
	private String telPhone;
	private StudentConstructor studentConstructor;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}

	public String getTelPhone() {
		return telPhone;
	}

	public void setTelPhone(String telPhone) {
		this.telPhone = telPhone;
	}
	/**
	 * 为什么方法可以重名?
	 */
	public StudentConstructor() {
	}
	/**
	 * 为什么方法可以重名?
	 */
	protected StudentConstructor(String name, String age) {
		this.name = name;
		this.age = age;
	}
	/**
	 * 为什么方法可以重名?
	 */
	private StudentConstructor(String name, String age, String telPhone) {
		super();
		this.name = name;
		this.age = age;
		this.telPhone = telPhone;
	}

	public static void main(String[] args) {
		new String("11");
		//以前的用法
		StudentConstructor studentConstructor  = new StudentConstructor();
		studentConstructor.setAge("123");
		studentConstructor.setName("张三");
		studentConstructor.setTelPhone("18412312312");
		
		
		//现在的用法
		StudentConstructor studentConstructor1 = new StudentConstructor("张三","10");
		StudentConstructor studentConstructor2 = new StudentConstructor("张三","10","18588123129");
		StudentConstructor studentConstructor3 = new StudentConstructor("张三","10","18588123129");
//		studentConstructor.setName("张三");
//		studentConstructor.setAge("10");
	}
}
